#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

struct Node {
    int val, idx;
    Node *left, *right;
    Node(int v, int i) : val(v), idx(i), left(nullptr), right(nullptr) {}
};

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    vector<Node*> nodes(n + 1);
    
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        nodes[i] = new Node(a[i], i);
    }
    
    // 建立双向链表
    for (int i = 1; i <= n; i++) {
        if (i > 1) nodes[i]->left = nodes[i - 1];
        if (i < n) nodes[i]->right = nodes[i + 1];
    }
    
    // 最大堆，按值排序
    auto cmp = [](Node* x, Node* y) { return x->val < y->val; };
    priority_queue<Node*, vector<Node*>, decltype(cmp)> pq(cmp);
    for (int i = 1; i <= n; i++) {
        pq.push(nodes[i]);
    }
    
    vector<int> team(n + 1, 0); // 0 未分配
    int ct = 1; // 当前队伍
    
    while (!pq.empty()) {
        Node* cur = pq.top();
        pq.pop();
        if (team[cur->idx] != 0) continue; // 已分配
        
        // 标记当前节点
        vector<Node*> tr;
        tr.push_back(cur);
        
        // 向左扩展 k 个
        Node* l = cur->left;
        for (int i = 0; i < k && l != nullptr; i++) {
            tr.push_back(l);
            l = l->left;
        }
        
        // 向右扩展 k 个
        Node* r = cur->right;
        for (int i = 0; i < k && r != nullptr; i++) {
            tr.push_back(r);
            r = r->right;
        }
        
        // 标记这些节点
        for (Node* node : tr) {
            if (team[node->idx] == 0) {
                team[node->idx] = ct;
            }
        }
        
        // 从链表中删除这些节点
        // 找到删除区间的最左和最右节点
        Node* lb = tr.back()->left;
        Node* rb = tr.back()->right;
        for (Node* node : tr) {
            if (node->left) lb = node->left;
            if (node->right) rb = node->right;
        }
        
        if (lb) lb->right = rb;
        if (rb) rb->left = lb;
        
        // 切换队伍
        ct = 3 - ct; // 1 -> 2, 2 -> 1
    }
    
    for (int i = 1; i <= n; i++) {
        cout << team[i];
        if (i < n) cout << " ";
    }
    cout << "\n";
}